package com.ouc.eddyAlgorithm.service.impl;

import com.github.pagehelper.PageHelper;
import com.ouc.eddyAlgorithm.domain.EddyFile;
import com.ouc.eddyAlgorithm.domain.PageInfo;
import com.ouc.eddyAlgorithm.mapper.EddyFileMapper;
import com.ouc.eddyAlgorithm.service.EddyFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EddyFileServiceImpl implements EddyFileService {

  @Autowired
  private EddyFileMapper eddyFileMapper;

  @Override
  public PageInfo<EddyFile> findByPage(Integer start, Integer rows) {
    PageHelper.startPage(start, rows);
    List<EddyFile> list = eddyFileMapper.findByPage(start, rows);
    return new PageInfo<>(start, rows, list, eddyFileMapper.getTotalNum());
  }

  @Override
  public PageInfo<EddyFile> findByPageByFilenameAndVariableName(Integer start, Integer rows, String filename, String variableName) {
    PageHelper.startPage(start, rows);
    List<EddyFile> list = eddyFileMapper.findByPageByFilenameAndVariableName(start, rows, filename, variableName);
    return new PageInfo<>(start, rows, list, eddyFileMapper.getTotalNumByFilenameAndVariableName(filename, variableName));
  }


}
